\section{lu --- LU decomposition}
\label{fn:lu}
\index{lu()}
\index{LU decomposition}
\begin{rail}
LU : 'lu' '(' Matrix ')' ;
\end{rail}

\verb+lu+ performs an LU decomposition of the matrix argument. The 
input matrix must be square and non-singular. \verb+lu+ returns 
the lower, upper and pivot matrices as the \verb+l+, \verb+u+ and
\verb+pvt+ elements of a list.  If the argument matrix is $A$, then
the decomposition has the form:

\[ A = pvt l u \] 

$\Longrightarrow$ This is not an \RLaB\ built-in function.  This function
is normally loaded on start-up from the \verb+lu.r+ file in the
standard \verb+rlib+ directory. Use of the \verb+-r+ option, incorrectly 
setting the \verb+RLAB_LIB_DIR+ environmental variable, or modifying
\verb+lu.r+ may make this function unavailable.


\paragraph{Example}
\index{example of lu()}
\index{lu()!example}
\begin{verbatim}
> a = rand(4,4)
 a =
    0.957      0.367      0.641      0.252  
     0.89      0.638      0.245      0.955  
    0.279       0.18      0.284      0.921  
     0.42      0.589      0.869      0.376  
> b = lu(a)
   l            pvt          u         
> b.l
 l =
        1          0          0          0  
    0.439          1          0          0  
     0.93      0.693          1          0  
    0.291      0.171    0.00416          1  
> b.u
 u =
    0.957      0.367      0.641      0.252  
        0      0.428      0.589      0.265  
        0          0     -0.758      0.537  
        0          0          0        0.8  
> b.pvt
 pvt =
        1          0          0          0  
        0          0          1          0  
        0          0          0          1  
        0          1          0          0  
> b.pvt*b.l*b.u
    0.957      0.367      0.641      0.252  
     0.89      0.638      0.245      0.955  
    0.279       0.18      0.284      0.921  
     0.42      0.589      0.869      0.376 
\end{verbatim}

See also: Page \pageref{fn:backsub} \verb+backsub()+,
 Page \pageref{fn:factor} \verb+factor()+,
 Page \pageref{fn:inv} \verb+inv()+,
 Page \pageref{fn:solve} \verb+solve()+.

\newpage






